using APP.HELPER.Utils.BarcodeLib;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;

namespace Common.UI
{
	public class XucBarcodeEdit : PictureEdit
	{
		private IContainer components = null;
		private new RepositoryItemPictureEdit fProperties;
		private SimpleButton btnPrint;
		public string Title
		{
			get
			{
				return this.Barcode.Title;
			}
			set
			{
				this.Barcode.Title = value;
				this.Update();
			}
		}
		public Font TitleFont
		{
			get
			{
				return this.Barcode.Font;
			}
			set
			{
				this.Barcode.Font = value;
				this.Update();
			}
		}
		public Font TextFont
		{
			get
			{
				return this.Barcode.TextFont;
			}
			set
			{
				this.Barcode.TextFont = value;
				this.Update();
			}
		}
		public ImageFormat ImageFormat
		{
			get
			{
				return this.Barcode.ImageFormat;
			}
			set
			{
				this.Barcode.ImageFormat = value;
			}
		}
		public BarCodeStyles Styles
		{
			get
			{
				return this.Barcode.Styles;
			}
			set
			{
				this.Barcode.Styles = value;
				this.Update();
			}
		}
		public string XML
		{
			get
			{
				return this.Barcode.XML;
			}
		}
		public double EncodingTime
		{
			get
			{
				return this.Barcode.EncodingTime;
			}
			set
			{
				this.Barcode.EncodingTime = value;
				this.Update();
			}
		}
		public bool ShowText
		{
			get
			{
				return this.Barcode.ShowText;
			}
			set
			{
				this.Barcode.ShowText = value;
				this.Update();
			}
		}
		public new Color BackColor
		{
			get
			{
				return this.Barcode.BackColor;
			}
			set
			{
				this.Barcode.BackColor = value;
				this.Update();
			}
		}
		public new Color ForeColor
		{
			get
			{
				return this.Barcode.ForeColor;
			}
			set
			{
				this.Barcode.ForeColor = value;
				this.Update();
			}
		}
		public Image EncodedImage
		{
			get
			{
				return this.Barcode.EncodedImage;
			}
		}
		public string EncodedValue
		{
			get
			{
				return this.Barcode.EncodedValue;
			}
		}
		public string FormattedData
		{
			get
			{
				return this.Barcode.FormattedData;
			}
		}
		public string Value
		{
			get
			{
				return this.Barcode.Text;
			}
			set
			{
				this.Barcode.Text = value;
				this.Update();
			}
		}
		public BarcodeEdit Barcode
		{
			get;
			private set;
		}
		public string CAMCode
		{
			get
			{
				return this.Barcode.CAM_Code;
			}
		}
		public bool Active
		{
			get;
			set;
		}
		public Size BarcodeSize
		{
			get
			{
				return new Size(this.Barcode.Width, this.Barcode.Height);
			}
			set
			{
				this.Barcode.Width = value.Width;
				this.Barcode.Height = value.Height;
			}
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(XucBarcodeEdit));
			this.fProperties = new RepositoryItemPictureEdit();
			this.btnPrint = new SimpleButton();
			((ISupportInitialize)this.fProperties).BeginInit();
			base.SuspendLayout();
			this.fProperties.Name = "fProperties";
			this.btnPrint.Image = (Image)componentResourceManager.GetObject("btnPrint.Image");
			this.btnPrint.Location = new Point(0, 0);
			this.btnPrint.Name = "btnPrint";
			this.btnPrint.Size = new Size(75, 23);
			this.btnPrint.TabIndex = 0;
			this.btnPrint.Text = "In";
			this.btnPrint.Visible = false;
			((ISupportInitialize)this.fProperties).EndInit();
			base.ResumeLayout(false);
		}
		public XucBarcodeEdit()
		{
			this.Barcode = new BarcodeEdit("Barcode", BarCodeStyles.CODE128);
			this.InitializeComponent();
			base.Controls.Add(this.btnPrint);
			base.Properties.SizeMode = PictureSizeMode.Stretch;
		}
		protected override void OnTextChanged(EventArgs e)
		{
			base.OnTextChanged(e);
			this.Barcode.Text = this.Text;
			this.Update();
		}
		internal void SetText(string text)
		{
			this.Barcode.Text = text;
		}
		protected override void OnAutoSizeChanged(EventArgs e)
		{
			base.OnAutoSizeChanged(e);
			this.Barcode.Width = base.Width;
			this.Barcode.Height = base.Height;
			this.Update();
		}
		public new void Update()
		{
			if (this.Active)
			{
				this.Image = this.Barcode.Encode(this.Barcode.Styles, this.Barcode.Text);
			}
		}
	}
}
